# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def user_img(user)
    return "<img src='/images/friends/#{user.os_id}.jpg' width='32' height='32'/> "
  end

  def dish_img(dish)
    return "<img src='/images/dishes/#{dish.base_dish.id}.gif'/> "
  end

  def base_dish_img(dish)
    return "<img src='/images/dishes/#{dish.id}.gif'/> "
  end

  def dish_label(dish)
     cmp_at = dish.completed_at
     if cmp_at > Time.now
       rest_minutes = (cmp_at - Time.now)/3600
       dish_label = "剩余时间:" + rest_minutes.to_i.to_s + "分钟"
     elsif @user.id == @view_user.id
       dish_label = link_to '出售', sold_dish_path(dish.id), :class => "a_button"
     else
       dish_label = link_to '偷吃', stole_dish_path(dish.id), :class => "a_button"
     end
     dish_label
  end # of dish_label
  
  def vegetable_img(vege)
    return "<img src='/images/vegetables/#{vege.id}.gif'/> "
  end

  def meat_img(meat)
    return "<img src='/images/meat/#{meat.id}.gif'/> "
  end

  def spice_img(spice)
    return "<img src='/images/spices/#{spice.id}.gif'/> "
  end

end
